package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author shiminghui
 * @date 2024/11/1 17:48
 * @description: TODO
 */
@RestController
@RequestMapping("/api/v1/channel")
public class WmChannelController {
    @Autowired
    private WmChannelService wmChannelService;

    @GetMapping("/channels")
    public ResponseResult list() {
        ResponseResult result = wmChannelService.channelList();
        return result;
    }

    /**
     * 删除
     *
     * @param id
     * @return
     */
    @GetMapping("del/{id}")
    public ResponseResult delete(@PathVariable("id") Long id) {
        ResponseResult result = wmChannelService.deleteById(id);
        return result;
    }

    /**
     * 分页查询
     *
     * @param dto
     * @return
     */
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmChannelDto dto) {
        ResponseResult responseResult = wmChannelService.list(dto);
        return responseResult;
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody WmChannel wmChannel) {
        ResponseResult result = wmChannelService.saveWmChannel(wmChannel);
        return result;
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody WmChannel wmChannel) {
        ResponseResult result = wmChannelService.update(wmChannel);
        return result;
    }

}
